import instance from "../../utils/util"
Page({
    data: {
        indicatorDots: true,
        vertical: false,
        autoplay: false,
        interval: 2000,
        duration: 500,
        banner: [],
        cate: [],
        hdone: "",
        hdtwo: "",
        hdthree: "",
        like: [],
        rqtj: []
    },
    onLoad(options) {
        this.getbanner()
        this.getcategiry()
        this.gethd()
        this.getlike()
        this.gettj()
    },
    async getbanner() {
        const res = await instance.get("/index/findBanner");
        console.log(res)
        this.setData({
            banner: res.data
        })
    },
    async getcategiry() {
        const res = await instance.get("/index/findCategory1");
        console.log(res)
        this.setData({
            cate: res.data
        })
    },
    async gethd() {
        const res = await instance.get("/index/advertisement");
        console.log(res)
        this.setData({
            hdone: res.data[0].imageUrl,
            hdtwo: res.data[1].imageUrl,
            hdthree: res.data[2].imageUrl,
        })
    },
    async getlike() {
        const res = await instance.get("/index/findListGoods");
        console.log(res)
        this.setData({
            like: res.data
        })

    },
   async gettj(){
        const res = await instance.get("/index/findRecommendGoods");
        console.log(res)
        this.setData({
            rqtj: res.data
        })
    },
    tzxq(e){
        console.log(e)
        wx.navigateTo({
          url: `/pages/shopinfo/shopinfo?id=${e.currentTarget.dataset.id}`,
        })
      },
    loglist(e){
        console.log(e)
        wx.navigateTo({
          url: `/pages/shoplist/shoplist?id=${e.currentTarget.dataset.id}`,
        })
    }

})